package com.example.fbsmobile;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.os.StrictMode;

public class ChangeBookingStatus
{
	public static String Update(String id, String status)
	{
		String result = "Not successful";
		StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.LAX);
		HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new
        HttpPost("http://10.10.2.139:8081/FBS.Team7/MobileUpdateStatusServlet");
        
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("id",id));
        params.add(new BasicNameValuePair("status",status));
        
        UrlEncodedFormEntity entity;
		try
		{
			entity = new UrlEncodedFormEntity(params,"UTF-8");
			httpPost.setEntity(entity);
        	System.out.println("execute");
			httpClient.execute(httpPost);
			result = "successful";
		} catch (UnsupportedEncodingException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}catch (ClientProtocolException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return result;
	}
}
